<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <canvas id="app" width="400" height="400"></canvas>
    <script src="utils.js"></script>
    <script src="ball.js"></script>
    <script>
        window.onload = function(){
            var canvas = document.getElementById('app'),
                context = canvas.getContext('2d'),
                angle = 0,
                centerX = canvas.width/2,
                centerY = canvas.height/2,
                radiusX = 100,
                radiusY = 150,
                speed = 0.05
            var ball = new Ball()
            function drawFrame(){
                window.requestAnimationFrame(drawFrame, context)
                context.clearRect(0,0,canvas.width, canvas.height)
                ball.x = centerX + Math.cos(angle)*radiusX
                ball.y = centerY + Math.sin(angle)*radiusY
                angle+=speed
                ball.draw(context)
            }
            drawFrame()
        }
    </script>

</body>
</html>